<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    年：<input type="text" id="year">
    月：<input type="text" id="month">
    日：<input type="text" id="day">
    <button id="btn">判断</button>
    <input type="text" id="result">
</body>
<script>
    var yearInp = document.getElementById("year");
    var monthInp = document.getElementById("month");
    var dayInp = document.getElementById("day");
    var btn = document.getElementById("btn");
    var resultInp = document.getElementById("result");

    // console.log(yearInp, monthInp, dayInp, btn, resultInp);

    btn.onclick = function () {
        // alert(1111111);
        var year = yearInp.value * 1;
        var month = monthInp.value * 1;
        var day = dayInp.value * 1;

        // if (month == 2) {
        //     if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {

        //     }
        // }
        //  计算该天是该年的第多少天
        var febDay = 28;  // 默认2月 28天
        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {  // 如果是闰年  则改为29
            febDay = 29;
        }

        // 2019-1-15    15
        // 2019-2-15    31+15 
        // 2019-3-15    31+(28/29)+15 
        // 2019-4-15    31+(28/29)+31+15 

        var count = 0;
        // if (month == 1) {
        //     count = day;
        // } else if (month == 2) {
        //     count = 31 + day;
        // } else if (month == 3) {
        //     count = 31 + febDay + day;
        // } else if (month == 4) {
        //     count = 31 + febDay + 31 + day;
        // } else if (month == 5) {
        //     count = 31 + febDay + 31 + 30 + day;
        // } else if (month == 6) {
        //     count = 31 + febDay + 31 + 30 + 31 + day;
        // } else if (month == 7) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + day;
        // } else if (month == 8) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + day;
        // } else if (month == 9) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + day;
        // } else if (month == 10) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
        // } else if (month == 11) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
        // } else if (month == 12) {
        //     count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
        // }
        switch(month){
            case 1:count=day;
            break;
            case 2:count = 31 + day;
            break;
            case 3:count = 31 + febDay + day;
            break;
            case 4:count = 31 + febDay + 31 + day;
            break;
            case 5:count = 31 + febDay + 31 + 30 + day;
            break;
            case 6:count = 31 + febDay + 31 + 30 + 31 + day;
            break;
            case 7:count = 31 + febDay + 31 + 30 + 31 + 30 + day;
            break;
            case 8:count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + day;
            break;
            case 9:count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + day;
            break;
            case 10:count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
            break;
            case 11:count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
            break;
            case 12:count = 31 + febDay + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
            break;
        }
        resultInp.value = count;

    }



</script>

</html>